<!DOCTYPE html>
<html lang="en" style="font-size: 100px">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>rem适配-1</title>
    <style>
        *{margin: 0;padding: 0}
        #banner{
            width: 3.35rem;
            height: 1.44rem;
            margin: 0.97rem auto 0;
            background: #c36;
        }
    </style>
</head>
<body>
    <div id="banner"></div>

    <script>
        function adapter(){
            //获得设备独立像素宽度
            let w = document.documentElement.clientWidth;
            //计算当前设备对应的根标签大小
            let fontSize = w * 100 / 375;
            //设置
            document.documentElement.style.fontSize = fontSize + 'px';
        }

        adapter();
        //当布局视口的大小发生改变的时候, 该事件会自动触发
        window.onresize = adapter;

    </script>
</body>
</html>